#ifndef DATA_STORAGE_H
#define DATA_STORAGE_H
#include "Arduino.h"
#include "module_general_reg.h"
#include "mail.h"
#include "module_header_reg.h"
#include "DataStorageBase.h"

class DataStorage : public DataStorageBase
{
public:
    typedef enum 
    {
        StatusNumber0 = 0,
        StatusNumber1 = 1,
        StatusNumber2 = 2,
        StatusNumber3 = 3
    }GeneralStatusName;

    DataStorage(Mail<>& mb);
    ~DataStorage();
    void begin();

    void make_default() override;

    bool load() override;

    int read_data_storage_eof() override;
    
    void check_update() override;

    module_header_reg_t& module_header_reg() override
    {
        return DataStorage::module_reg().module_header_reg;
    }

    data_storage_reg_read_t& get_reg_data(uint8_t reg_address) override;
    
    
    static module_reg_t& module_reg()
    {
        static module_reg_t module_reg;
        return module_reg;
    }

    constexpr uint32_t data_storage_header_size()
    {
        return sizeof(module_header_reg_t);
    }
private:
    Mail<>& _mb;
    data_storage_eof_t _data_storage_eof;

    data_storage_reg_read_t _reg_read;
};


#endif